package com.ggs.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.ggs.anno.State;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import jakarta.validation.groups.Default;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import java.time.LocalDateTime;

@Data
public class Article {

  @NotNull(groups = Update.class)
  private Long id;
  @NotEmpty
  @Pattern(regexp = "^[\\u4e00-\\u9fa5]{1,10}$")
  private String title;
  @NotEmpty
  private String content;
  @NotEmpty
  @URL
  private String coverImg;
  @NotEmpty
//  @Pattern(regexp = "^(已发布|草稿)$")
  @State
  private String state;
  @NotNull
  private Long categoryId;
  @JsonIgnore
  private long createUser;
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  private LocalDateTime createTime;
  @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
  private LocalDateTime updateTime;

  public interface  Add extends Default {}

  public interface Update extends Default {}

}

